const webpack = require('webpack');
const Merge = require('webpack-merge');
const CommonConfig = require('./webpack.common.js');
const AliOssPlugin = require('webpack-alioss-plugin');

module.exports = Merge(CommonConfig, {
  devtool: 'source-map',
  output: {
    publicPath: 'https://imgcdn.hypereal.com/oss-test/',
  },
  plugins: [
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false
    }),
    new webpack.optimize.UglifyJsPlugin({
      beautify: false,
      mangle: {
        screw_ie8: true,
        keep_fnames: true
      },
      compress: {
        warnings: false,
        screw_ie8: true,
        conditionals: true,
        unused: true,
        comparisons: true,
        sequences: true,
        dead_code: true,
        evaluate: true,
        if_return: true,
        join_vars: true
      },
      comments: false,
      sourceMap: true
    }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new AliOssPlugin({
      accessKeyId: 'eLXOPxnsnVlpabKV',
      accessKeySecret: 'BZUnDhcIIH8ExWBFqmNkjFQpEgIkBT',
      bucket: 'hyperimage',
      prefix: 'oss-test',
      region: 'oss-cn-shenzhen',
      exclude: /.*\.html$/,
      enableLog: true
    })
  ]
});
